<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title></title>
    <link rel="stylesheet" href="./css/mui-3.7.2.css">
    <link rel="stylesheet" href="./css/reset.css">
    <!-- 当前页css -->
    <link rel="stylesheet" href="./css/personal-info.css">
    <!-- <link rel="stylesheet" href="./css/animate.css"> -->
</head>
<body>
<!-- 父容器 -->
<div class="container">
    <!-- 顶部头 -->
    <div class="top clearfix">
        <div class="back fl">返回</div>
        <div class="title fl">个人信息</div>
        <div class="save fr">保存</div>
    </div>
    <!-- 个人信息内容 -->
    <div class="content">
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media photo">
                <div class="content">
                    <div class="inner-photo mui-media-object mui-pull-right">
                    </div>
                    <span class="item">头像</span>
                </div>
            </li>
        </ul>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell nickname">
                <div class="content">

                    <span class="item">姓名</span>
                    <input type="text" class="item-content" placeholder="">
                </div>
            </li>
            <li class="mui-table-view-cell tel">
                <div class="content">
                    <span class="item">手机号</span>
                    <input type="text" disabled class="item-content" placeholder="18625512982">
                </div>
            </li>
        </ul>
    </div>


</div>

<!-- 移动端适配 -->
<script src="./js/flexible.js"></script>
<script src="./js/mui-3.7.2.js"></script>
<script src="./js/jquery.js"></script>
<script src="./js/ajax.js"></script>
<script src="./js/index.js"></script>
<script>
    //返回跳转
    //    jump('.back', 'mine.html');
    var getParams = function (data) {
        var passData = JSON.parse(data);
        var studentId = passData.studentId;

        //获取个人信息
        getPersonInfo(
            {
                studentId: studentId
            },
            function (res) {
                console.log(res);
                //渲染页面：
                //用户头像：
                var img = $('<img src=""/>');
                img.attr('src',res.data.headimgurl);
                $('.inner-photo').css({
                    'animation': 'none'
                });
                $('.inner-photo').html(img);
                //用户名：
                $('.nickname .item-content').val(res.data.nickName);
                //手机号：
                $('.tel .item-content').val(res.data.phone);


                //保存修改过的个人信息：
                $('.save').on('click', function () {
                    var nickname = $('.nickname .item-content').val();
                    if ($.trim(nickname) == '') {
                        mui.toast('请输入内容后提交！');
                        return;
                    }
                    savePersonInfo(
                        {
                            'studentId': res.data.studentId,
                            'nickName': nickname
                        },
                        function (res) {
                            console.log(res);
                            //错误处理：
                            if (res.code != 200) {
                                mui.toast(res.msg);
                                return;
                            }
                            mui.toast(res.msg);
                        });
                });
            });
    }
</script>
<script src="./js/personal-info.js"></script>
</body>
</html>
